﻿using System;
using System.IO;
using log4net.Appender;
using log4net.Config;
using log4net.Layout;

namespace TY.UC.Log4
{
    public class Log4NetConfig
    {
        public static void RegisterLog4Net()
        {
            var file = new FileInfo("log4net.config");
            if (!file.Exists)
            {
                file = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4net.config"));
            }

            if (file.Exists)
            {
                XmlConfigurator.ConfigureAndWatch(file);
            }
            else
            {
                BasicConfigurator.Configure(new ConsoleAppender { Layout = new PatternLayout() });
            }
        }
    }
}